//
//  LZRetrieveTitleView.m
//  laziz_Consumer
//
//  Created by ZhaoDongBo on 2016/10/26.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZRetrieveTitleView.h"

#import "Masonry.h"


@interface LZRetrieveTitleView ()

@property (nonatomic, strong) UIImageView * logoImageView;
@property (nonatomic, strong) UILabel * subLabel;

@end

@implementation LZRetrieveTitleView

- (instancetype)initWithPage:(LZRETRIEVE_TITLE_PAGE)page {
    
    self = [super init];
    if (self) {

        self.page = page;
        
        [self setup];
    }
    return self;
}

- (void)setup {
    
    GET_SCREEN_SCALE(scale);
    
    [self addSubview:self.logoImageView];
    [self addSubview:self.subLabel];
    
    [self.logoImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.centerX.equalTo(0);
    }];
    
    [self.subLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.logoImageView.mas_bottom).with.offset(20*scale);
        make.leading.mas_equalTo(50*scale);
        make.trailing.mas_equalTo(-50*scale);
    }];
    
}

- (void)setSubTitleText:(NSString *)subTitleText {
    _subTitleText = [subTitleText copy];
    
    NSMutableAttributedString * attributedString    = [[NSMutableAttributedString alloc] initWithString:_subTitleText];
    NSMutableParagraphStyle * paragraphStyle        = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing  = 5.0f;
    paragraphStyle.alignment    = NSTextAlignmentCenter;//设置对齐方式
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [_subTitleText length])];
    [self.subLabel setAttributedText:attributedString];
}

- (UIImageView *)logoImageView {
    if (_logoImageView == nil) {
        _logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lz_logo_white"]];
    }
    return _logoImageView;
}

- (UILabel *)subLabel {

    if (_subLabel == nil) {
        
        GET_SCREEN_SCALE(scale);
        
        _subLabel = [[UILabel alloc] init];
        _subLabel.textColor     = UIColorFromRGB(0xcccccc, 1);
        _subLabel.font          = [UIFont fontWithName:@"Arial-ItalicMT" size:15*scale];
        _subLabel.textAlignment = NSTextAlignmentCenter;
        _subLabel.numberOfLines = 2;
    }
    
    return _subLabel;
}

@end
